{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "game stats.ipynb", "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "pycharm": { "stem_cell": { "cell_type": "raw", "source": [], "metadata": { "collapsed": false } } } }, "cells": [ { "cell_type": "markdown", "source": [ "# Game statistics\n", "## Problem definition\n", "You would like to build a program to collect statistics for a basketball game. The objective is to build a chatbot like assistant with the following logic and functionality: \n", "- Ask the user what is the name of the event\n", "- Ask the user the name of one of the teams\n", "- Ask the user for the name of the second team\n", "- Ask the user to confirm the start of the game\n", "- Once the name has started, ask the user if he wants to register a game statistic, either a fault or game points, or if he wants to stop the game: \n", " - if the user wants to register a fault, ask the user the number of the player and team that made the fault, and the number of the player that received the fault. Show a message with the total number of faults made by the player.\n", " - if the user wants to register points, ask the user for the player number and the team that score the points and if it´s a 1 point, 2 point or a 3 point shot. Show a message with the total number of points socred by the player. \n", "\n", "It is very important to register the date and time of every statistic, including the game start. To store this type of information, you can use the [datetime](https://docs.python.org/3/library/datetime.html) Python library, which provides convenient data types to deal with time and dates. Specifically, you can use: \n", "- ```datetime.datetime.now()```: This functions returns a datetime object with the current date and time. \n", "- ```isoformat()```: this datetime object method returns a string with the date and time in [ISO standard format](https://en.wikipedia.org/wiki/ISO_8601)\n", "\n", "Also, you may use a Python dictionaries to store the information of the statistics. This way, you can initialise the stats registry as an array: \n", "\n", "```python\n", "stats_array = []\n", "```\n", "\n", "And then, use the information provided by the user to build different dictionaries to store the information required for each type of statistic. The key *type* can be used to identify the type of statistic. The following code snippet contain examples for each type of statistic:\n", "\n", "```python\n", "# Game start\n", "{'type': 'game_start', 'timestamp': '2022-01-05T11:42:03.792167', 'teams': ['Valencia Basket', 'Real Madrid']}\n", "\n", "# Shot\n", "{'type': 'shot', 'timestamp': '2022-01-05T11:43:17.030771', 'player': 7, 'points': 3, 'team': 0} \n", "\n", "# Fault\n", "{'type': 'fault', 'timestamp': '2022-01-05T11:43:45.966949', 'player': 6, 'team': 1, 'received_by': 11}]\n", "```\n", "\n", "Design the flow diagram for the main chatbot and the functions required to show the statistics of each player and build a Python program to implement this chatbot\n" ], "metadata": { "id": "vbwOgs0p-JCD", "pycharm": { "name": "#%% md\n" } } } ] }